package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.BmsImportantActivitiesSlideshow;
import com.macro.mall.portal.dto.BmsImportantActivitiesSlideshowParam;
import com.macro.mall.portal.service.BmsImportantActivitiesSlideshowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 重要活动Controller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "BmsImportantActivitiesSlideshowController")
@Tag(name = "BmsImportantActivitiesSlideshowController", description = "重要活动管理")
@RequestMapping("/importantactivitiesslide")
public class BmsImportantActivitiesSlideshowController {
    @Autowired
    private BmsImportantActivitiesSlideshowService bmsImportantActivitiesSlideshowService;





    @ApiOperation("分页查询重要活动")
    @RequestMapping(value = "/mpList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsImportantActivitiesSlideshow>> getList(@RequestBody BmsImportantActivitiesSlideshowParam bmsImportantActivitiesSlideshowParam) {
        List<BmsImportantActivitiesSlideshow> bmsImportantActivitiesSlideshowList = bmsImportantActivitiesSlideshowService.getList(bmsImportantActivitiesSlideshowParam);
        return CommonResult.success(CommonPage.restPage(bmsImportantActivitiesSlideshowList));
    }

    @ApiOperation("根据id获取重要活动信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsImportantActivitiesSlideshow> getItem(@PathVariable Long id) {
        BmsImportantActivitiesSlideshow bmsImportantActivitiesSlideshowList = bmsImportantActivitiesSlideshowService.getItem(id);
        if (null == bmsImportantActivitiesSlideshowList){
            BmsImportantActivitiesSlideshow bmsImportantActivitiesSlideshow = new BmsImportantActivitiesSlideshow();
            return CommonResult.success(bmsImportantActivitiesSlideshow);
        }
        return CommonResult.success(bmsImportantActivitiesSlideshowList);
    }


}
